Security News
Research
Supply Chain Attack on Rspack npm Packages Injects Cryptojacking Malware
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
object-loops
Advanced tools
Functional methods like forEach, map, filter, and other ES5 Array methods for Objects in javascript
Functional methods like forEach, map, filter, and other ES5 Array methods for Objects in javascript
npm install object-loops
require('object-loops')();
// obj.forEach()
var objForEach = require('object-loops/for-each');
objForEach({ x:10, y: 20 }, callback, thisArg);
Executes a provided function once per each object value.
require('object-loops')(); // extends Object.prototype
var obj = {
foo: 10,
bar: 20,
baz: 30
};
var keyConcat = '';
var valSum = 0;
obj.forEach(function (val, key, obj) {
keyConcat += key;
valSum += val;
});
keyConcat; // = 'foobarbaz'
valSum; // = 60
Creates a new object with the results of calling a provided function on every value in the object.
require('object-loops')(); // extends Object.prototype
var obj = {
foo: 10,
bar: 20,
baz: 30
};
var mappedObj = obj.map(function (val, key, obj) {
return val*2;
});
mappedObj; /* Each val multiplied by 2
{
foo: 20,
bar: 40,
baz: 60
}
*/
Creates a new object with all entries that pass the test implemented by the provided function.
require('object-loops')(); // extends Object.prototype
var obj = {
foo: 10,
bar: 20,
baz: 30,
qux: 40,
};
var filteredObj = obj.filter(function (val, key, obj) {
return val > 25;
});
filteredObj; /* Only has entries with vals greater than 25
{
baz: 30,
qux: 40
}
*/
Applies a function against an accumulator and each value of the object to reduce it to a single value.
require('object-loops')(); // extends Object.prototype
var obj = {
foo: 10,
bar: 20,
baz: 30
};
var valSum = obj.reduce(function (prevVal, val, key, obj) {
return prevVal + val;
});
valSum; // 60
MIT
FAQs
Functional methods like forEach, map, filter, and other Array methods for Objects in javascript
We found that object-loops demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.
Security News
Sonar’s acquisition of Tidelift highlights a growing industry shift toward sustainable open source funding, addressing maintainer burnout and critical software dependencies.